package cn.mesmile.flink.demo;

import org.apache.flink.api.java.tuple.Tuple3;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author zb
 * @date 2021/8/20 22:34
 * @Description
 */
public class MapDemo {

    public static void main(String[] args) {
        Tuple3<Integer, String, Double> test = Tuple3.of(1, "test", 3.14);
        System.out.println("test.f0 = " + test.f0);
        System.out.println("test.f1 = " + test.f1);
        System.out.println("test.f2 = " + test.f2);

        List<String> stringList = new ArrayList<>();
        stringList.add("springboot,testone");
        stringList.add("springtest,testtwo");
        stringList.add("spring,testthree");
        // 一转多
        List<String> collect = stringList.stream().flatMap(obj -> {
            String[] split = obj.split(",");
            Stream<String> stream = Arrays.stream(split);
            return stream;
        }).collect(Collectors.toList());
        System.out.println("collect = " + collect);

    }
}
